// *********************************************************
//      Copyright (c) Kosta Gaitanis
//      All rights reserved
//
//      k.gaitanis@gmail.com
//
// *********************************************************

#ifndef COLLAPSIBLEWIDGET_H
#define COLLAPSIBLEWIDGET_H

#include <QFrame>
#include <QGroupBox>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QTimeLine>

class CollapsibleWidget : public QFrame
{
    Q_OBJECT
public:
    explicit CollapsibleWidget(QWidget *parent = 0);

    void setTitle(const QString& title);
    void setWidget(QWidget* widget);

    bool isCollapsed() const;
    void toggleCollapsed();
    void setCollapsed(bool collapsed);


protected:
    bool eventFilter(QObject *o, QEvent *e);

private slots:
    void onFrameChanged(int frame);

private:
    bool m_isCollapsed;
    QVBoxLayout *m_mainLayout;
    QLabel *m_collapseButton;
    QLabel *m_title;
    QWidget *m_widget;
    QTimeLine *m_timeLine;
    QSize m_sizeHint;

};

#endif // COLLAPSIBLEWIDGET_H
